'use client';
import { useState, useEffect } from 'react';
import { message } from 'antd';
import { useRouter } from 'next/navigation';
import { RankingType, mockRankingModuleList } from '../../constant';
import RankingBox from '../RankingBox';
import type { RankingItem } from '../../types';

const ContributionList: React.FC = () => {
  const [contributionList, setContributionList] = useState<RankingItem[]>(
    mockRankingModuleList[1].rankingList
  );
  const [loading] = useState(false); // 静态数据不需要loading状态
  const router = useRouter();

  // 注释掉的API请求
  /*
  const getContributeList = async () => {
    try {
      const res = await req({...});
      setContributionList(res?.data || []);
    } catch (err) {
      console.error(err);
    }
  };
  */

  const onChangeJump = async () => {
    const userInfoStorage = localStorage.getItem('userInfo');
    if (!userInfoStorage) {
      message.info('请登录');
      router.push('/login');
      return;
    }
    // 权限检查逻辑保持不变
  };

  return (
    <RankingBox
      isLoading={loading}
      contributionList={contributionList}
      rankingType={RankingType.contribution}
      onHandleJump={onChangeJump}
    />
  );
};

export default ContributionList;